package com.kaussoft.lolblog.action;

import java.util.Map;

import com.kaussoft.lolblog.bo.ServiceManager;
import com.kaussoft.lolblog.util.AccountThreadLocal;
import com.kaussoft.lolblog.vo.Account;
import com.opensymphony.webwork.interceptor.SessionAware;
import com.opensymphony.xwork.ActionSupport;

public class AbstractAction extends ActionSupport implements SessionAware{

	private static final long serialVersionUID = 1L;
	
	private ServiceManager serviceManager;
	private Map<String, Object> session;
	private Account account;

	public Object get(String name) {
		return session.get(name);
	}
	
	public void set(String name, Object value) {
		session.put(name, value);
	}

	public ServiceManager getServiceManager() {
		return serviceManager;
	}

	public void setServiceManager(ServiceManager serviceManager) {
		this.serviceManager = serviceManager;
	}

	@SuppressWarnings("unchecked")
	public void setSession(Map session) {
		this.session = session;
	}

	public Account getAccount() {
		if (account == null) {
			account = AccountThreadLocal.get();
		}
		return account;
	}
	
}
